package com.testMain;

import com.example.user.entity.User;

import java.io.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 贾明祯
 * @ClassName TestMain
 * @Date 2020/9/3 15:00
 * @Introduce
 */
public class TestMain {
    public static void main(String[] args) throws IOException {
        File file = new File("D:/督查问题.docx");
        FileInputStream fileInputStream = new FileInputStream(file);
        BufferedInputStream bfi = new BufferedInputStream(fileInputStream);
        byte[] tempbytes = new byte[1024];
        int bytes = 0;
        int i =0;
        System.out.println(file.length());
        int lenth = 0;
        File files = new File("F:/督查.doc");
        FileOutputStream outputStream = new FileOutputStream(files);
        BufferedOutputStream bfo = new BufferedOutputStream(outputStream);
        DecimalFormat df=new DecimalFormat("0.0");
        while ((bytes=bfi.read(tempbytes))!=-1){
            lenth += bytes;
            System.out.println(df.format(((float)lenth/(float)file.length())*100)+"%");
            bfo.write(tempbytes,0,bytes);
        }

        bfo.close();
        outputStream.close();
        bfi.close();
        fileInputStream.close();
        files.delete();

    }
}
